{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<!DOCTYPE html>\n",
      "<html lang=\"zh-CN\">\n",
      "<head>\n",
      "    <meta charset=\"utf-8\">\n",
      "    <title>百度安全验证</title>\n",
      "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n",
      "    <meta name=\"apple-mobile-web-app-capable\" content=\"yes\">\n",
      "    <meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black\">\n",
      "    <meta name=\"viewport\" content=\"width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0\">\n",
      "    <meta name=\"format-detection\" content=\"telephone=no, email=no\">\n",
      "    <link rel=\"shortcut icon\" href=\"https://www.baidu.com/favicon.ico\" type=\"image/x-icon\">\n",
      "    <link rel=\"icon\" sizes=\"any\" mask href=\"https://www.baidu.com/img/baidu.svg\">\n",
      "    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge\">\n",
      "    <meta http-equiv=\"Content-Security-Policy\" content=\"upgrade-insecure-requests\">\n",
      "    <link rel=\"stylesheet\" href=\"https://wappass.bdimg.com/static/touch/css/api/mkdjump_8befa48.css\" />\n",
      "</head>\n",
      "<body>\n",
      "    <div class=\"timeout hide\">\n",
      "        <div class=\"timeout-img\"></div>\n",
      "        <div class=\"timeout-title\">网络不给力，请稍后重试</div>\n",
      "        <button type=\"button\" class=\"timeout-button\">返回首页</button>\n",
      "    </div>\n",
      "    <div class=\"timeout-feedback hide\">\n",
      "        <div class=\"timeout-feedback-icon\"></div>\n",
      "        <p class=\"timeout-feedback-title\">问题反馈</p>\n",
      "    </div>\n",
      "\n",
      "<script src=\"https://wappass.baidu.com/static/machine/js/api/mkd.js\"></script>\n",
      "<script src=\"https://wappass.bdimg.com/static/touch/js/mkdjump_6003cf3.js\"></script>\n",
      "</body>\n",
      "</html><!--09339564200438000650050122-->\n",
      "<script> var _trace_page_logid = 0933956420; </script>\n"
     ]
    }
   ],
   "source": [
    "from urllib.request import urlopen,Request\n",
    "from urllib.parse import quote,urlencode\n",
    "url=\"https://www.baidu.com/s?{}\".format(quote('图片'))\n",
    "\n",
    "headers={\n",
    "    \"User-Agent\":\" Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763\"\n",
    "    \n",
    "}\n",
    "request=Request(url,headers=headers)\n",
    "response=urlopen(request)\n",
    "print(response.read().decode())\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
